<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:f="http://java.sun.com/jsf/core"  
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

    <ui:composition template="../index.xhtml">
        <ui:define name="conteudo">
            <h:form id="tituloPagina">
                <h:outputText value="Cadastro de Impressoras"/>
            </h:form>
            <h:form id="formTabelaImpressora">
                <p:growl id="msgImpre"/>
                <p:dataTable id="listImpressora" var="forn" value="#{impressoraControler.listImpressoras}" widgetVar="carsTableAtivos" 
                             rowKey="#{forn.id}" selectionMode="single"  emptyMessage="Nenhum registro foi encontrado!" paginator="true" rows="10" rowsPerPageTemplate="5,10,15">
                    <f:facet name="header" >  
                        <p:outputPanel>  
                            <h:outputText value="Digite para pesquisar " />
                            <p:inputText id="globalFilter" onkeyup="carsTableAtivos.filter()" style="width:150px" /> 
                            <p:commandButton value="Novo" accesskey="N" onclick="dlgImpressora.show()" action="#{impressoraControler.inicializaObj()}" update=":formAddImpre"/>
                        </p:outputPanel>  
                    </f:facet>  
                    <p:column headerText="Ações" footerText="Ações" filterMatchMode="Ações" style="width: 60px;">  
                        <p:commandButton action="#{impressoraControler.setImpressora(forn)}" onclick="dlgImpressora.show();" update=":formAddImpre"
                                         image="ui-icon ui-icon-pencil" title="alterar" />
                        <p:commandButton image="ui-icon ui-icon-close" title="excluir" 
                                         actionListener="#{impressoraControler.setImpressora(forn)}" onclick="confirmationExcluirgrupo.show();"/>
                    </p:column>
                    <p:column filterBy="${forn.marca}" headerText="Marca" footerText="Marca" sortBy="${forn.marca}">    
                        <h:outputText value="${forn.marca}" />  
                    </p:column>  
                    <p:column filterBy="${forn.modelo}" headerText="Modelo" footerText="Modelo" sortBy="${forn.modelo}">    
                        <h:outputText value="${forn.modelo}" />  
                    </p:column>  
                    <p:column filterBy="${forn.serie}" headerText="Nº série" footerText="Nº série" sortBy="${forn.serie}">    
                        <h:outputText value="${forn.serie}" />  
                    </p:column>  
                    <p:column filterBy="${forn.versao}" headerText="Versão" footerText="Versão" sortBy="${forn.versao}">    
                        <h:outputText value="${forn.versao}" />  
                    </p:column>  
                </p:dataTable>
            </h:form>
            <p:dialog id="dialogImpre" header="Nova impressora" widgetVar="dlgImpressora" modal="true" resizable="false" appendToBody="true">  
                <h:form id="formAddImpre">
                    <p:messages/>
                    <h:inputHidden value="#{impressoraControler.impressora.id}"/>
                    <h:panelGrid columns="2">
                        <h:outputText value="Código"/>
                        <p:inputText value="#{impressoraControler.impressora.id}" disabled="true" size="5"/>

                        <h:outputText value="Marca: "/>
                        <p:inputText value="#{impressoraControler.impressora.marca}" required="true" requiredMessage="Informe a marca da impressora!!">
                            <p:focus/>
                        </p:inputText>

                        <h:outputText value="Modelo: "/>
                        <p:inputText value="#{impressoraControler.impressora.modelo}" required="true" requiredMessage="Informe o modelo da impressora"/>

                        <h:outputText value="Código: "/>
                        <p:inputText value="#{impressoraControler.impressora.codigo}" required="true" requiredMessage="Informe o codigo da impressora"/>

                        <h:outputText value="Identificação: "/>
                        <p:inputText value="#{impressoraControler.impressora.identificacao}" required="true" requiredMessage="Informe a identificação da impressora" size="50"/>
                    </h:panelGrid>
                    <h:panelGrid columns="12">
                        <h:outputText value="MC: "/>
                        <p:inputText value="#{impressoraControler.impressora.mc}" required="true" requiredMessage="Informe o codigo de MC da impressora" size="2" maxlength="2"/>

                        <h:outputText value="MD: "/>
                        <p:inputText value="#{impressoraControler.impressora.md}" required="true" requiredMessage="Informe o codigo de MD da impressora" size="2" maxlength="2"/>

                        <h:outputText value="VR: "/>
                        <p:inputText value="#{impressoraControler.impressora.vr}" required="true" requiredMessage="Informe o codigo de VR da impressora" size="2" maxlength="2"/>

                        <h:outputText value="Tipo: "/>
                        <p:inputText value="#{impressoraControler.impressora.tipo}" required="true" requiredMessage="Informe o tipo da impressora" size="2" maxlength="2"/>

                        <h:outputText value="Modelo ACBR: "/>
                        <p:inputText value="#{impressoraControler.impressora.modeloAcbr}" required="true" requiredMessage="Informe o modelo da ACBR da impressora" size="2" maxlength="2"/>

                        <h:outputText value="Versão: "/>
                        <p:inputText value="#{impressoraControler.impressora.versao}" required="true" requiredMessage="Informe a versão da impressora" size="10"/>

                    </h:panelGrid>
                    <h:panelGrid columns="8">
                        <h:outputText value="LE: "/>
                        <p:inputText value="#{impressoraControler.leImp}" size="2" maxlength="1"/>

                        <h:outputText value="LEF: "/>
                        <p:inputText value="#{impressoraControler.impressora.lef}" required="true" requiredMessage="Informe o codigo de LEF da impressora" size="2" maxlength="1"/>

                        <h:outputText value="Lacre na MFD: "/>
                        <p:selectOneMenu value="#{impressoraControler.impressora.lacreNaMfd}">  
                            <f:selectItem itemValue="S" itemLabel="SIM"/> 
                            <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                        </p:selectOneMenu>

                        <h:outputText value="MFD: "/>
                        <p:selectOneMenu value="#{impressoraControler.impressora.mfd}">  
                            <f:selectItem itemValue="S" itemLabel="SIM"/> 
                            <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                        </p:selectOneMenu>

                    </h:panelGrid>
                    <h:panelGrid columns="6">
                        <h:outputText value="DCTO: "/>
                        <p:inputText value="#{impressoraControler.impressora.docto}" required="true" requiredMessage="Informe o DCTO da impressora" />

                        <h:outputText value="Nº ECF: "/>
                        <p:inputText value="#{impressoraControler.impressora.numeroEcf}"  size="8"/>

                        <h:outputText value="MD adicional: "/>
                        <p:selectOneMenu value="#{impressoraControler.impressora.mfAdicional}">  
                            <f:selectItem itemValue="S" itemLabel="SIM"/> 
                            <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                        </p:selectOneMenu>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <h:outputText value="Data instalação SB: "/>
                        <p:calendar value="#{impressoraControler.impressora.dataInstalacaoSb}" locale="pt" showOn="button" size="10">
                            <f:convertDateTime pattern="dd-MM-yyyy"/>  
                        </p:calendar>

                        <h:outputText value="Hora instalação Sb: "/>
                        <p:inputText value="#{impressoraControler.impressora.horaInstalacaoSb}"  />

                    </h:panelGrid>

                    <h:panelGrid columns="3">
                        <p:commandButton value="Salvar" action="#{impressoraControler.salvar()}" update="formAddImpre :formTabelaImpressora" onclick="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                        <p:commandButton value="Novo" accesskey="N" update=":formAddImpre" action="#{impressoraControler.inicializaObj()}" process="@this"/>
                        <p:commandButton value="Cancelar" onclick="dlgImpressora.hide()" process="@this"/>
                    </h:panelGrid>
                </h:form>
                <!-- confirmações  de exclusão-->
                <h:form>
                    <p:confirmDialog id="confirmDialogImpre" message="Confirma excluir este impressora?" appendToBody="true"
                                     header="Atenção!!!" severity="alert" widgetVar="confirmationExcluirgrupo" >  
                        <p:commandButton id="confirmImpre" value="Sim" oncomplete="confirmationExcluirgrupo.hide()"  
                                         actionListener="#{impressoraControler.excluir()}" update=":formTabelaImpressora"/>  
                        <p:commandButton id="declinee" value="Cancelar" onclick="confirmationExcluirgrupo.hide()" type="button" />   
                    </p:confirmDialog>
                </h:form>
            </p:dialog>
        </ui:define>
    </ui:composition>
</html>